@extends('admin.layout')

@section('content')
    <div class="console-content">
        <div class="page-header">
            <h2 id="nav">@if(isset($trade)) 编辑产品 @else 添加产品 @endif</h2>
        </div>
        <div class="well bs-component">
            @form(['url' => isset($trade)? admin_url('trade/update/' . $trade->id): admin_url('trade/create'), 'method' => 'post', 'class' => 'form-horizontal', 'enctype' => 'multipart/form-data'])
            @col_input('text','name',$errors,'*产品名称',isset($trade) ? $trade->name : old('name'), ['placeholder' => '产品名称'])
            @col_select('cate_id', $categories, $errors,'*产品分类',isset($trade) ? $trade->cate_id : old('cate_id'), ['placeholder' => '产品分类'])
            @col_input('text', 'number', $errors, '*产品编号', isset($trade) ? $trade->number : old('number'), ['placeholder' => '产品编号'])
            @col_input('text', 'price', $errors, '*产品价格', isset($trade) ? $trade->price : old('price'), ['placeholder' => '产品价格'])
            @col_input('textarea', 'brief', $errors, '*产品简介', isset($trade) ? $trade->brief : old('brief'), ['placeholder' => '产品简介'])
            @if(isset($trade))

                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">产品图片</label>
                    <div class="col-sm-6">
                        <input type="file" name="logo" id="logo" />
                        <img src="{{ $trade->logo }}" alt="" style="width: 100px; height: 100px;">
                    </div>
                </div>
                <input type="hidden" name="id" value="{{ $trade->id }}">
            @else
                @col_input('file', 'logo', $errors, '*产品图片', isset($trade) ? $trade->logo : old('logo'), ['placeholder' => '产品图片'])
            @endif

            @col_submit('提交')
            @endform
        </div>
    </div>
@endsection